import json
import time
import requests
from urllib3.exceptions import InsecureRequestWarning
import datetime

# 禁用安全请求警告
Platform = "袋鼠书城_污院小说"

today = datetime.date.today()  # 今天
yester = today - datetime.timedelta(days=1)
yesterday = str(yester).replace('-', '')


def daishu1():
    try:
        requests.urllib3.disable_warnings(InsecureRequestWarning)
        r = requests.session()
        url = "https://www.ziread.cn/admin/index/login"
        date = {
            "username": "",
            "password": ""
        }
        rr = r.post(url=url, data=date, verify=False, timeout=15)
        header = {
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36",
            "X-Requested-With": "XMLHttpRequest"
        }
        aa = r.get(
            url="https://www.ziread.cn/admin/collect/index?channel_id=0&sort=createdate&order=desc&offset=0&limit=10",
            headers=header, verify=False, timeout=15)
        html = json.loads(aa.text)
        for y in range(len(html['rows'])):
            date_time = html['rows'][y]['createdate']
            if str(date_time) == str(yesterday):
                date_time = str(yesterday)
                Amount_share = html["rows"][y]["recharge_money_benefit"]
                return date_time, Amount_share, Platform
            else:
                if y == len(html['rows']) - 1:
                    return '', 'None', Platform
                else:
                    pass
    except Exception:
        print("获取 袋鼠书城_污院小说 数据失败")
        return '', 'None', Platform
    except ConnectionError:
        print("获取 袋鼠书城_污院小说 数据 超时")
        return '', 'None', Platform